/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import dataAccess.UsersJpaController;
import entities.Users;
import java.util.List;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author QUY-THI
 */
public class CheckUser {

    public Users checkUser(String username) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("E-AdministrationPU");
        UsersJpaController cl = new UsersJpaController(emf);
        List<Users> findUsersEntities = cl.findUsersEntities();
        for (Users users : findUsersEntities) {
            if (users.getUsername().equals(username)) {
                return users;
            }
        }
        return null;
    }
}
